package com.naiterui.ehp.bs.doctor.dao.mongo;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

@Repository
public class AdEduReadNumber extends MongoBaseDao {

    private static final String COLLECTION_NAME = "m_edu_read_number";

    @Resource
    private MongoTemplate mongoTemplate;

    @Override
    protected MongoTemplate getMongoTemplate() {
        return this.mongoTemplate;
    }

    /**
     * @param doctorId
     * @param eduId
     *
     * @return
     *
     * @since 1.0.0
     */
    public int getEduReadCount(Long doctorId, Long eduId) {
        Criteria criteria = Criteria.where("doctorId").is(doctorId).and("eduId").is(eduId);
        // 查询
        Query query = Query.query(criteria);
        return (int) super.queryCount(query, COLLECTION_NAME);
    }

}
